#include <iostream>

class Solution
{
public:
    int main()
    {
        int weekDay, span;
        std::cin >> weekDay >> span;
        int mile = 0;
        mile += 250 * (span / 7) * 5;
        span = span % 7;
        for (int i = 0; i < span; ++i)
        {
            if (((weekDay + i) != 6) && ((weekDay + i) != 7))
            {
                mile += 250;
            }
        }
        std::cout << mile;
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif